﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using DevExpress.XtraEditors;
using System.Data;
using DevExpress.XtraEditors.Controls;
using DevExpress.XtraReports.Parameters;

namespace Waker.Reports
{
    public partial class ReportThreeSafeEdu : Base.ReportBase
    {
        public ReportThreeSafeEdu()
        {
            InitializeComponent();
            this.BeforePrint += new System.Drawing.Printing.PrintEventHandler(ReportThreeSafeEdu_BeforePrint);
            this.ParametersRequestBeforeShow += new EventHandler<DevExpress.XtraReports.Parameters.ParametersRequestEventArgs>(ReportThreeSafeEdu_ParametersRequestBeforeShow);
        }
        void ReportThreeSafeEdu_ParametersRequestBeforeShow(object sender, DevExpress.XtraReports.Parameters.ParametersRequestEventArgs e)
        {
            DataTable dt = new BAL.BAL_Cards().GetAllDepartment();
            ImageComboBoxEdit icb = new ImageComboBoxEdit();
            foreach (ParameterInfo info in e.ParametersInformation)
            {
                if (info.Parameter.Name == "parameter1")
                {
                    //icb.Properties.Items.Add(new ImageComboBoxItem("全部", ""));
                    foreach (DataRow dr in dt.Rows)
                    {
                        icb.Properties.Items.Add(new ImageComboBoxItem(dr["Dept_Name"].ToString(), dr["Dept_ID"].ToString()));
                    }
                    info.Editor = icb;
                }
            }
            icb.SelectedIndex = 0;
        }
        void ReportThreeSafeEdu_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            if (string.IsNullOrEmpty(parameter1.Value.ToString()))
            {
                return;
            }
            DataTable dt = new BAL.BAL_Report().GetThreeSafeEduRecord(parameter1.Value.ToString());
            FillReportData(dt);
        }
    }
}
